package cn.itcast.bos.service.base.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.itcast.bos.dao.base.AreaRepository;
import cn.itcast.bos.domain.base.Area;
import cn.itcast.bos.service.base.AreaService;
@Service
@Transactional
public class AreaServiceImpl implements AreaService {

	@Autowired
	private AreaRepository areaRepository;
	@Override
	public void save(Area area) {
		areaRepository.save(area);
	}
	@Override
	public Page<Area> findByQuery(Specification<Area> specification,
			Pageable pageable) {
		
		return areaRepository.findAll(specification, pageable);
	}
	@Override
	public void saveBatch(List<Area> areas) {
		//参数是对象Iterable，而list集合继承了Collection，Collection继承了Iterable
		areaRepository.save(areas);
	}
	@Override
	public void updateDelflag(String tag, String ids) {
		String[] idString = ids.split(",");
		Character log=null;
		if (tag.equals("1")) {
			log=tag.charAt(0);
		}
		for (String id : idString) {
			areaRepository.updateDelflag(log,id);
		} 
		
	}
	@Override
	public Area findAreaById(String stringCellValue) {
		return areaRepository.findOne(stringCellValue);
	}
	@Override
	public List<Area> areafindAll() {
		return areaRepository.findAll();
	}
	

}
